package org.example.game.history;

import java.util.HashMap;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/05/25 22:35
 */
public class Solution100303 {


    public int[] occurrencesOfElement(int[] nums, int[] queries, int x) {

        HashMap<Integer, Integer> indexMap = new HashMap();
        for(int i=0;i<nums.length;i++){
            if(nums[i] == x){
                indexMap.put(indexMap.size() + 1, i);
            }
        }

        int[] res = new int[queries.length];
        for(int j=0;j<queries.length;j++){
            if(indexMap.containsKey(queries[j])){
                res[j] = indexMap.get(j);
            }else {
                res[j] = -1;
            }
        }

        return res;

    }

}
